<?php
/**
 * The template for displaying Category Archive pages.
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */

get_header(); ?>

<section id="primary">
	<div id="content" role="main">
			<?php 
			$category = get_the_category();
			$paged = get_query_var('paged') ? get_query_var('paged'): 1;
			
			$sticky_query = new WP_Query();
			if (  get_option ( 'sticky_posts' ) ) {
				$sticky_query->query ( array (
						'post__in' => get_option ( 'sticky_posts' ),
						'orderby' => 'title',
						'order' => 'ASC',
						'cat' => '' . $category [0]->cat_ID . '',
						'paged' => $paged 
				) );
				if ($sticky_query->have_posts ()) :
					while ( $sticky_query->have_posts () ) :
						$sticky_query->the_post ();
						get_template_part ( 'content', 'top-news' );
					endwhile
					;
				endif;
			}
			
			?>
			<?php if ( have_posts() ) : ?>

				<?php while ( have_posts() ) : the_post(); ?>
					<?php if (is_sticky()):?>
						<?php /*get_template_part( 'content', 'top-news' );*/?>
					<?php else: ?>
						<?php get_template_part( 'content', get_post_format() ); ?>
					<?php endif; ?>
				<?php endwhile; ?>

				<?php build_page_steps();?>

			<?php else : ?>

				<article id="post-0" class="post no-results not-found">
			<header class="entry-header">
				<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
			</header>
			<!-- .entry-header -->

			<div class="entry-content">
				<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven' ); ?></p>
						<?php get_search_form(); ?>
					</div>
			<!-- .entry-content -->
		</article>
		<!-- #post-0 -->

			<?php endif; ?>

			</div>
	<!-- #content -->
</section>
<!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>
